home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / cpphtp2 / code.jar / code / ch03 / fig03_03.txt next >
Text File  |  1998-02-27  |  427b  |  21 lines

  1. 1   // Fig. 3.3: fig03_03.cpp
  2. 2   // Creating and using a programmer-defined function
  3. 3   #include <iostream.h>
  4. 4   
  5. 5   int square( int );   // function prototype
  6. 6   
  7. 7   int main()
  8. 8   {
  9. 9      for ( int x = 1; x <= 10; x++ )
  10. 10        cout << square( x ) << "  ";
  11. 11  
  12. 12     cout << endl;
  13. 13     return 0;
  14. 14  }
  15. 15  
  16. 16  // Function definition 
  17. 17  int square( int y )
  18. 18  {
  19. 19     return y * y;
  20. 20  }
  21.